package com.qq.BFMRSE.BussinessService;

import com.qq.BFMRSE.DAO.userDAO;
import com.qq.BFMRSE.model.user;

public class userBusSerImpl {
	private userDAO userDao;
	public userBusSerImpl(userDAO userDao){
		this.userDao=userDao;
	}
	public userBusSerImpl(){}
	public void setUserDao(userDAO userDao){
		this.userDao=userDao;
	}
	public userDAO getUserDao(){
		return userDao;
	}
	/**
	 * 添加新用户
	 * @param newUser
	 * @return
	 */
	public int addNewUser(user  newUser){
		return userDao.addNewUser(newUser.getUserName(), newUser.getPwd(), newUser.getEmail());
	}
	/**
	 *  判断登陆是否成功
	 * @param userName
	 * @param pwd
	 * @return
	 */
	public boolean isLogin(String userName,String pwd){
		String rePwd=userDao.getPwd(userName);
		if((!"".equals(rePwd))&&rePwd.equals(pwd))
			return true;
		else {
			return false;
		}
	}
	/**
	 *  删除用户
	 * @param userName
	 * @return
	 */
	public int deleteUser(String userName){
		return userDao.deleteUser(userName);
	}
	/**
	 * 判断用户名是否存在
	 * @param userName
	 * @return
	 */
	public boolean isUserNameUnUsed(String userName){
		return !userDao.isUserExist(userName);
	}
	

}
